<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-07-22 10:16
 *
 * Version: 2.0
 */

namespace App\Modules\Member\Criterias;


use Flower\Core\Repository\Contracts\RepositoryInterface;
use Flower\Core\Repository\Criterias\BaseCriterias;
use Illuminate\Support\Facades\DB;

class getMemberInfoCriteria extends BaseCriterias
{
	private $memberId;
	public function __construct($memberId)
	{
		$this->memberId = $memberId;
	}

	public function apply($model, RepositoryInterface $repository)
	{
		$where['id'] = $this->memberId;
		return $model
			->withCount(['order'=>function($query){
					$query->where('order.status' ,'=',config('constant.orderStatus.confirm'));
			}])
			// ->with('memberCard')
			->withCount(['storeLike','couponList','memberCard'=>function($query){
			    $query->where('status',1);
            },'portfolioLike'])
			->where($where);
	}
}